﻿using GalaSoft.MvvmLight.CommandWpf;
using GEPL.StandardModulesLibrary.Models;
using PropertyChanged;
using System.Collections.ObjectModel;
using System.Windows.Input;

namespace GEPL.StandardModulesLibrary.ViewModels.Console
{
    [ImplementPropertyChanged]
    public class ConsoleWriteViewModel
    {
        public ObservableCollection<WriteItem> WriteList { get; set; }

        public bool WriteLine { get; set; }

        public WriteItem SelectedItem { get; set; }

        public ICommand AddTextBoxCommand { get; set; }

        public ICommand RemoveTextBoxCommand { get; set; }

        public ConsoleWriteViewModel()
        {
            WriteList = new ObservableCollection<WriteItem> { new WriteItem() };
            InitCommands();
        }

        private void InitCommands()
        {
            AddTextBoxCommand = new RelayCommand(AddTextBox);
            RemoveTextBoxCommand = new RelayCommand(RemoveTextBox, () => SelectedItem != null);
        }

        public void AddTextBox()
        {
            WriteList.Add(new WriteItem());
        }

        public void RemoveTextBox()
        {
            if (SelectedItem == null)
                return;
            WriteList.Remove(SelectedItem);
        }
    }
}